package gw.com.android.greendao;

import android.content.Context;

import org.greenrobot.greendao.database.Database;

/**
 * @author jett
 * @since 2018-09-07.
 */
public class MyOpenHelper extends DaoMaster.DevOpenHelper {

    MyOpenHelper(Context context, String name) {
        super(context, name);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        for (int i = oldVersion + 1; i <= newVersion; i++) {
            handleUpgrade(db, i);
        }
    }

    private void handleUpgrade(Database db, int version) {
        switch (version) {
            case 2:
                db.execSQL("alter table " + NotifyDataDao.TABLENAME + " add " + NotifyDataDao.Properties.IsBurn.columnName + " integer default 0");
                db.execSQL("alter table " + NotifyDataDao.TABLENAME + " add " + NotifyDataDao.Properties.CreateTime.columnName + " integer");
                db.execSQL("alter table " + NotifyDataDao.TABLENAME + " add " + NotifyDataDao.Properties.DisplaySecond.columnName + " integer");
                break;
            case 3:
                break;
            default:
                break;
        }
    }

}
